package com.jcp.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.jcp.entity.Users;

import tk.mybatis.mapper.common.Mapper;

@Repository
public interface UsersMapper extends Mapper<Users> {
	
	@Select("select * from Users where carNumber=#{carNumber} or phoneNumber=#{phoneNumber}")
	public List<Users> selectChong(Users users);
	
	@Select("select count(0) from Record where enter_time like #{time}")
	public int selectCountEnterCar(@Param(value="time")String time);
	
	@Select("select count(0) from Record where out_time like #{time}")
	public int selectCountOutCar(@Param(value="time")String time);
	//消费金额
	@Insert("INSERT into Parment(payTime,payment_amount,carNumber,paymentType) VALUE(NOW(),#{payment_amount},#{carNumber},0)")
	public int addparmt(@Param(value="payment_amount")String payment_amount,@Param(value="carNumber")String carNumber);
	//充值金额
	@Insert("INSERT into Parment(payTime,payment_amount,carNumber,paymentType) VALUE(NOW(),#{payment_amount},#{carNumber},1)")
	public int addparmt1(@Param(value="payment_amount")String payment_amount,@Param(value="carNumber")String carNumber);
	
	@Select("select * from Users where phoneNumber=#{phoneNumber} and password=#{password}")
	public Users selectLogin(Users users);
	
	@Insert("insert into Users(carNumber,userName,password,phoneNumber,remainder,carModel,carColor)values(#{carNumber},#{userName},#{password},#{phoneNumber},0,#{carModel},#{carColor})")
	public int insertUsers(Users users);
}
